/*
 * Features.cpp
 *
 *  Created on: Jan 4, 2014
 *      Author: thanhkm
 */

#include "Features.h"

Features::Features() {
	hessianThreshold = 500;
}

Features::~Features() {
}

void Features::compute(const std::vector<cv::Mat> &images){
	// for computing descriptors
	cv::SiftFeatureDetector detector(hessianThreshold);
	cv::SiftDescriptorExtractor extractor;

	// variables for save all the descriptors
	// and their keypoints
	std::vector<cv::KeyPoint> keypoints;
	cv::Mat descriptors;

	// compute the descriptors of images
	// and save them to allKeypoints and allDescriptors
	detector.detect(images, allKeypoints);
	extractor.compute(images, allKeypoints, allDescriptors);
}

void Features::computeKeypoints(const std::vector<cv::Mat> &images){
	// for computing descriptors
	cv::SiftFeatureDetector detector(hessianThreshold);
	cv::SiftDescriptorExtractor extractor;

	// variables for save all the descriptors
	// and their keypoints
	std::vector<cv::KeyPoint> keypoints;
	cv::Mat descriptors;

	// compute the descriptors of images
	// and save them to allKeypoints and allDescriptors
	detector.detect(images, allKeypoints);
}
int Features::numberKeypoints(){
	int nbImage = allKeypoints.size();
	int nbKeypoints = 0;
	for (int i = 0; i < nbImage; i++){
		nbKeypoints += allKeypoints[i].size();
	}

	return nbKeypoints;
}

std::vector<std::vector<cv::KeyPoint>> Features::getKeypoints(){
	return allKeypoints;
}

std::vector<cv::Mat> Features::getDescritpors(){
	return allDescriptors;
}

void Features::setHessianThreshold(int thresh){
	hessianThreshold = thresh;
}
